/**
 * @author NGUYEN Van Tho
 */

package ifi.p17.controler;

import ifi.p17.Person;
import ifi.p17.model.Model;
import ifi.p17.view.MainView;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.List;

import javax.swing.JButton;

import javax.swing.JPanel;

public class Control extends JPanel{
	
	private static final String LABEL_SAVE = "Enregistrer";
	private static final String LABEL_CANCEL = "Annuler";

    private Model model;    
    JButton buttonSave = new JButton(LABEL_SAVE);
    JButton buttonCancel = new JButton(LABEL_CANCEL);

    
    public Control(Model model){
    	this.model = model;
    }

    public boolean insertPerson(Person person){
    	boolean result = model.insert(person);
    	if(result){
    		
    	}
    	
    	return result;
    }
    
    public void setMainView(MainView mainView){
    	this.model.setMainView(mainView);
    }
    public void changeView(String key){
    	this.model.changeView(key);
    }
    
    public void changeToDetailAndClear(){
    	this.model.changeToDetailAndClear();
    }
    public Model getModel(){
    	return model;
    }
    
    public List<Person> search(String searchName){
    	return model.getPersons(searchName);
    }
}
